-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
567/user-data-dir-config #630
Conversation
.refine( | ||
(value) => { | ||
// Simplified regex to match both absolute and relative paths | ||
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test( |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 16 days ago
To fix the problem, we need to modify the regular expression to remove the ambiguity that can lead to exponential backtracking. Specifically, we should replace the [\w]+
pattern with a more precise pattern that avoids ambiguity. One way to achieve this is to use a non-capturing group with a negated character class to ensure that each character is matched in a deterministic way.
- Replace the
[\w]+
pattern with(?:[\w-]+)
to ensure that the pattern matches sequences of word characters and hyphens without causing exponential backtracking. - Update the regular expression in the
path
validator function in thelib/envs.js
file.
-
Copy modified line R75
@@ -74,3 +74,3 @@ | ||
// Simplified regex to match both absolute and relative paths | ||
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?(([\w]+|-)[\\/]?)+$/.test( | ||
return /^(\.\/|\.\.\/|\/|[a-zA-Z]:\\|[a-zA-Z]:\/)?((?:[\w-]+)[\\/]?)+$/.test( | ||
value |
…ression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Added the PUPPETEER_TEMP_DIR option, touch #567.
INFO:
Based on the @jszuminski's PR: #569.